<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>冀兴驾校--手机版</title>

<link rel="icon" type="image/x-icon" href="http://www.jixingjx.com/favicon.ico" />

<meta name="keyword" content="冀兴驾校,冀兴驾校手机版,jixingjiaxiao"/>

<meta name="description" content="冀兴驾校手机版，让你更快更准确地找到冀兴驾校！"/>

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2"></script>

<style>

body,html,#jx_map{height:100%;width:100%;padding:0;margin:0;font-size:14px;}

</style>

</head>

<body>

<div id="jx_map"></div>

</body>

<script type="text/javascript">

var map = new BMap.Map("jx_map");

map.centerAndZoom("北京", 14);

map.addControl(new BMap.MapTypeControl({mapTypes:[BMAP_NORMAL_MAP, BMAP_HYBRID_MAP], anchor:BMAP_ANCHOR_TOP_LEFT}));

map.addControl(new BMap.NavigationControl({type:BMAP_NAVIGATION_CONTROL_ZOOM, anchor:BMAP_ANCHOR_BOTTOM_RIGHT}));


// 定义一个控件类

function MyLocation(){

  this.defaultAnchor = BMAP_ANCHOR_TOP_RIGHT;

  this.defaultOffset = new BMap.Size(10, 10);

}

MyLocation.prototype = new BMap.Control();

MyLocation.prototype.initialize = function(map){

  var div = document.createElement("div");

  div.appendChild(document.createTextNode("定位"));

  // 设置样式

  div.style.cursor = "pointer";

  div.style.border = "1px solid gray";

  div.style.backgroundColor = "white";

  div.style.padding = "10px";

  div.style.borderRadius = "5px";

  div.onclick = function(e){

    var geolocation = new BMap.Geolocation();

    geolocation.getCurrentPosition(function(r){

        if(this.getStatus() == BMAP_STATUS_SUCCESS){

            var mk = new BMap.Marker(r.point);

            map.addOverlay(mk);

            map.panTo(r.point);

            gc.getLocation(r.point, function(rs){

                var sContent = "您的位置是:</br>" + rs.address;    

                var infoWindow = new BMap.InfoWindow(sContent, {width:150, offset:new BMap.Size(0,-20)});

                map.openInfoWindow(infoWindow, r.point);  

            });

        }

        else {

            alert("网络不通，请稍后再试。");

        }

    })

  }

  map.getContainer().appendChild(div);

  return div;

}

var mylocation = new MyLocation();  //定位

map.addControl(mylocation); 



var gc = new BMap.Geocoder();  //地址解析

</script> 
 
dgfd
</html>